package com.yuji.aacar.widgets.dialogue;

import android.content.Context;
import android.graphics.Color;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;
import android.widget.Toast;

import com.yuji.aacar.R;


public class CheckToast {
    private static Toast mToast;

    public static void showToast(Context mContext, String text, int duration) {
        try {
            mToast = Toast.makeText(mContext, text, duration);
            View view = LayoutInflater.from(mContext).inflate(R.layout.view_toast, null);
            TextView tv = (TextView) view.findViewById(R.id.toast_tv);
            tv.setText(text);
            tv.setTextColor(Color.WHITE);
            mToast.setDuration(duration);
            mToast.setView(view);
            mToast.setGravity(Gravity.CENTER, 0, 0);
            mToast.show();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public static void showToast(Context mContext, int resId, int duration) {
        showToast(mContext, mContext.getResources().getString(resId), duration);
    }

    public static void cancle() {
        if (mToast != null) {
            mToast.cancel();
        }
    }
}
